package com.telnetnz.ticketdesk.action.base;

import org.apache.log4j.Logger;

import com.rockbb.common.sso.session.SessionConstants;
import com.telnetnz.ticketdesk.bean.User;
import com.telnetnz.ticketdesk.service.UserService;

public class BasicSessionPageLogAction extends BasicSessionPageAction
{
	private static Logger logger = Logger.getLogger(BasicSessionPageLogAction.class);

	public String intercepters()
	{
		String result = super.intercepters();
		if (result == null || result.equals(SUCCESS))
		{
			User user = getSessionUser();

			if (user.getId() == SessionConstants.USER_ID_ANONYMOUS)
			{
				return message_box(
						langRes.get("user.need-register-or-login"), 
						langRes.get("user.need-register-or-login-message", new String[]{baseLink("userlogin")}),
						baseLink("userlogin"),
						2);
			}

			// Halt in-activated users
			if (user.getStatus() == UserService.USER_STATUS_INACTIVATED)
			{
				return message_box(
						langRes.get("user.account-be-forbidden"), 
						langRes.get("user.account-be-forbidden-message"));
			}

		}
		return result;
	}
}
